package com.example.mypplication

import android.content.Context
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bumptech.glide.Glide
import com.example.mypplication.databinding.ActivityGlideTestBinding

/**
 * 测试Glide内存泄漏的问题
 * 场景：
 * 在GLide加载图片的时候，退出了界面，会不会引发内存泄漏
 * 检查方式：使用adb检查当前界面情况
 *
 * 待实现
 */
class GlideTestActivity : AppCompatActivity() {
    private lateinit var mBinding: ActivityGlideTestBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        mBinding = ActivityGlideTestBinding.inflate(layoutInflater)
        setContentView(mBinding.root)

        initGlideLater()

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }

    private fun initGlideLater() {
        Glide.with(this)
            .load(R.drawable.gogo_gif)
            .into(mBinding.imgIv)
    }
}